<template>
	<view>
		<view class="head">
			<view class="head_left" @click="fanhui">
				<image src="http://oos-cn.ctyunapi.cn/hfclass/fanhui.png?Signature=UxKzt/fO7QiCKXVEBjkGnSGdoIw%3D&AWSAccessKeyId=65b300139cc5a0aa9572&Expires=865585101242"
				 style="width: 16rpx;height: 30rpx;margin-right: 20rpx;"></image>
				<text>返回</text>
			</view>
			<view style="position: relative;left: -16rpx;">选择上报</view>
			<view class="head_right">
			</view>
		</view>

		<view class="conent">
			<view class="entBox" v-for="(item,index) in list" :key='index'>
				<view class="entTop" @click="examine(item.userId)">
					<view class="entTopLeft">
						<view>{{item.name}}</view>
						<view>{{item.identityNumber}}</view>
					</view>
					<view class="entTopRight">
						<text>详情</text>
						<image src="http://oos-cn.ctyunapi.cn/hfclass/%E9%80%89%E6%8B%A9%E7%AE%AD%E5%A4%B415X22.png?Signature=8Ry%2BydghTC67iii673JW%2BmJlX5s%3D&AWSAccessKeyId=65b300139cc5a0aa9572&Expires=865585102035"></image>
					</view>
				</view>
				<view class="entBottom">
					<view class="entBottomLeft jc" @click="del(item.userId)">
						<image src="http://oos-cn.ctyunapi.cn/hfclass/shanchu.png?Signature=69LjqfiCxPT6azt5qDLhODvPn5E%3D&AWSAccessKeyId=65b300139cc5a0aa9572&Expires=865585101910"></image>
						<text>解除绑定</text>
					</view>
					<view class="entBottomLeft sctx" @click="uploading(item.userId)" v-if="item.isHasFace">
						<image src="../../static/tabbar/sctx.png"></image>
						<text>上传头像</text>
					</view>
					<view class="entBottomLeft cw" @click="renlcew(item.userId)" v-if="item.isHasFace">
						<image src="../../static/tabbar/rlcw.png"></image>
						<text>人脸测温</text>
					</view>
					<view class="entBottomLeft entBottomRight" @click="sbao(index)">
						<image src="../../static/tabbar/twsb.png"></image>
						<text>上报体温</text>
					</view>

					<view class="entBottomLeft entBottomRight" @click="dayforteenHealthList(item.userId)">
						<image src="../../static/tabbar/twenbefore.png"></image>
						<text>14天上报记录</text>
					</view>
				</view>
			</view>

			<view class="oppt"></view>

			<view class="modification">
				<view @click="amend" class="ends">
					<image src="http://oos-cn.ctyunapi.cn/hfclass/jia.png?Signature=WdAqxK3P05%2Bg96miUAoBsgcrf%2Bg%3D&AWSAccessKeyId=65b300139cc5a0aa9572&Expires=865585101961"></image>
					<text>添加上报人</text>
				</view>
			</view>
		</view>

		<view v-if="loadModal" class="MaskLayer"></view>
		<view class="gif" v-if="loadModal">
			<view>
				<image src="http://oos-cn.ctyunapi.cn/hfclass/jiazai.gif?Signature=OgNX%2BUIeALb4HM35vCGC1jX%2BZEw%3D&AWSAccessKeyId=65b300139cc5a0aa9572&Expires=865585100785"></image>
				<view>请耐心等待！</view>
			</view>
		</view>

		<!-- 删除弹窗 -->
		<view v-if="isFix" class="MaskLayer"></view>
		<view class="fixedes" v-if="isFix">
			<view class="fixedbox">
				<view class="fixedboxTop">你确定要解除绑定吗？</view>
				<view class="fixedboxBottom">
					<view @click="isFix=false">取消</view>
					<view @click="sure">确定</view>
				</view>
			</view>
		</view>





		<view v-if="IsRelieve" class="MaskLayer"></view>
		<view class="CPM" v-if="IsRelieve">
			<view class="CPM_box">
				<view>添加上报人信息</view>
				<view @click="confirm">确定</view>
			</view>
		</view>
	</view>
</template>

<script>
	import App from '../../App.vue'
	export default {
		data() {
			return {
				list: [],
				IsRelieve: false,
				loadModal: false,
				isFix: false,
				userId: '',
				sbUserId: ''
			}
		},

		created() {

			this.getList()
			//this.getuserID()
		},
		methods: {
			uploading(userId) {
				uni.navigateTo({
					url: '/pages/submit/photo?id=' + userId
				})
			},
			dayforteenHealthList(userId) {


				uni.navigateTo({
					url: '/pages/submit/beforedayshealthlist?id=' + userId
				})

			},


			renlcew(userId) {
				uni.navigateTo({
					url: '/pages/submit/renlcews?id=' + userId
				})
			},
			// getuserID() {
			// 	var that = this
			// 	// that.loadModal=true
			// 	uni.request({
			// 		method: 'POST',
			// 		url: App.globalData.baseUrl + '/api/services/app/session/GetCurrentLoginInformations',
			// 		success(res) {
			// 			// console.log(res)
			// 			if (res.data.result == null || res.data.result.user == undefined || res.data.result.user == null || res.data.result
			// 				.user == '') {
			// 				// that.loadModal=false
			// 				uni.showToast({
			// 					icon: 'none',
			// 					duration: 2000,
			// 					title: '未登录'
			// 				})
			// 				let cl = setTimeout(() => {
			// 					window.location.href = '/wx/GetCode'
			// 					clearTimeout(cl)
			// 				}, 2000)
			// 			} else {
			// 				that.userId = res.data.result.user.id
			// 				that.getList()
			// 			}
			// 		},
			// 		fail(res) {
			// 			// that.loadModal=false
			// 			uni.showToast({
			// 				title: res.data.error.message,
			// 				duration: 1000,
			// 				icon: 'none',
			// 			})
			// 		}
			// 	})
			// },
			getList() {
				let that = this
				that.loadModal = true
				uni.request({
					method: 'POST',
					url: App.globalData.baseUrl + '/api/services/app/organUser/GetBingList',
					success(res) {
						
						if (res.data.success == true) {
							const ultarr = res.data.result
							ultarr.sort(function(a, b) {
								return b.name.length - a.name.length
							})
							
							
							if (ultarr.length == 1 && ultarr[0].address == null && ultarr[0].familyCount == 0 && ultarr[0].identityNumber ==
								null &&
								ultarr[0].name == '' && ultarr[0].phoneNumber == null) {
								that.userId = ultarr[0].userId
								that.IsRelieve = true
							} else {
								that.list = res.data.result
							}
							that.loadModal = false
						} else {
							that.loadModal = false
							that.IsRelieve = false
							uni.showToast({
								title: res.data.error.message,
								duration: 2000,
								icon: 'none'
							})
							if (res.data.error.code == 401) {
								
								
								uni.showToast({
									icon: 'none',
									duration: 2000,
									title: '马上开始重新登录'
								})

								let cl = setTimeout(() => {
									window.location.href = '/wx/GetCode?PageId=1'
									clearTimeout(cl)
								}, 2000)


							}
						}
					},
					fail(res) {
						that.loadModal = false
						that.IsRelieve = false
						// uni.showToast({
						// 	title: res.data.error.message,
						// 	duration: 2000,
						// 	icon: 'none'
						// })
						uni.showToast({
							icon: 'none',
							duration: 2000,
							title: '未登录'
						})
						let cl = setTimeout(() => {
							window.location.href = '/wx/GetCode?PageId=1'
							clearTimeout(cl)
						}, 2000)
						// that.getuserID()
					}
				})
			},
			del(userId) { //删除上报人
				this.isFix = true
				this.sbUserId = userId //上报人id
				const ArrId=uni.getStorageSync('ArrId')
				let inc=ArrId.findIndex((item)=>{
					return item.userId==userId
				})
				ArrId.splice(inc, 1)
				uni.setStorageSync('ArrId', ArrId)
			},
			sure() {
				let that = this
				this.isFix = false //删除弹窗关闭
				that.loadModal = true //转圈弹窗出来
				uni.request({
					method: 'POST',
					url: App.globalData.baseUrl + '/api/services/app/organUser/BatchBindUser',
					data: JSON.stringify([that.sbUserId]),
					success(res) {
						if (res.data.success == true) {
							that.loadModal = false
							uni.showToast({
								title: '删除成功',
								icon: 'none',
								duration: 2000
							})
							if (that.list.length == 1) {

								let cl = setTimeout(() => {
									window.location.href = '/wx/GetCode?PageId=1'
									clearTimeout(cl)
								}, 2000)
							} else {

								that.getList()
							}
						} else {
							that.loadModal = false
							uni.showToast({
								title: res.data.error.message,
								icon: 'none',
								duration: 2000
							})
							if (res.data.error.code == 401) {
								
								uni.showToast({
									icon: 'none',
									duration: 2000,
									title: '马上开始重新登录'
								})

								let cl = setTimeout(() => {
									window.location.href = '/wx/GetCode?PageId=1'
									clearTimeout(cl)
								}, 2000)


							}
						}
					},
					fail(res) {
						that.loadModal = false
						uni.showToast({
							title: res.data.error.message,
							icon: 'none',
							duration: 2000
						})
					}

				})
			},
			fanhui() {
				uni.redirectTo({
					url: '/pages/submit/DataReport'
				})
			},
			confirm() {
				this.IsRelieve = false
				uni.navigateTo({
					url: '/pages/submit/CompleteInformation?userId=' + this.userId
				})
				
			},
			examine(userId) {
				uni.navigateTo({
					url: '/pages/submit/register?userId=' + userId
				})
			},
			amend() {
				let that = this
				if (that.list.length >= 5) {
					uni.showToast({
						title: '上报人不能超过5个人哦！',
						icon: 'none',
						duration: 2000
					})
				} else {
					uni.navigateTo({
						url: '/pages/submit/CompleteInformation'
					})
				}
			},
			sbao(index) {
				uni.navigateTo({
					url: '/pages/submit/DataReport?index=' + index
				})
			},
			// getshanchu(){
			// 	var that=this
			// 	that.loadModal=true
			// 	uni.request({
			// 		method:'POST',
			// 		url:App.globalData.baseUrl + '/api/services/app/session/GetCurrentLoginInformations',
			// 		success(res) {
			// 			// console.log(res)
			// 			if(res.data.result==null||res.data.result.user==undefined||res.data.result.user==null||res.data.result.user==''){
			// 				that.loadModal=false
			// 				let cl=setTimeout(()=>{
			// 					window.location.href='/wx/GetCode'
			// 					clearTimeout(cl)
			// 				},2000)
			// 			}
			// 		},fail(res) {
			// 			that.loadModal=false
			// 			uni.showToast({
			// 				title:res.data.error.message,
			// 				duration:1000,
			// 				icon:'none'	,
			// 			})
			// 		}
			// 	})
			// }
		}
	}
</script>

<style scoped>
	.head {
		height: 120rpx;
		width: 100%;
		background-color: #FFFFFF;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 30rpx;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 10;
	}

	.head_left {
		display: flex;
		align-items: center;
	}

	.head_right {
		position: relative;
	}

	.sctx>text {
		color: #0081FF;
	}

	.conent {
		width: 100%;
		height: 100%;
		padding-top: 120rpx;
	}

	.entBox {
		width: 100%;
		background: #FFFFFF;
		margin-top: 20rpx;
		font-size: 30rpx;
	}

	.entTop {
		height: 80rpx;
		padding: 0 30rpx;
		border-bottom: 1rpx solid #DDDDDD;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.entTopLeft,
	.entTopRight {
		display: flex;
		align-items: center;
	}

	.entTopLeft>view:nth-child(1) {
		margin-right: 20rpx;
	}

	.entTopRight>image {
		width: 15rpx;
		height: 30rpx;
		margin-left: 20rpx;
	}

	.modification {
		width: 100%;
		display: flex;
		justify-content: center;
		position: fixed;
		bottom: 100rpx;
	}

	.entBottomLeft {
		display: flex;
		align-items: center;
	}

	.jc>text {
		color: red;
	}

	.cw>text {
		color: #FF6C00;
	}

	.entBottomLeft>image {
		width: 26rpx;
		height: 26rpx;
		margin-right: 10rpx;
	}

	.entBottom {
		height: 110rpx;
		display: flex;
		padding: 0 30rpx;
		box-sizing: border-box;
		align-items: center;
		justify-content: space-between;
	}

	.entBottomLeft>text {
		font-size: 26rpx;
	}

	.entBottomRight>text {
		color: #21D2A1;
	}

	.modification>view {
		width: 500rpx;
		height: 90rpx;
		border-radius: 60rpx;
		font-size: 32rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #FFFFFF;
		background-color: #1CBBB4;
	}

	.ends>image {
		width: 28rpx;
		height: 28rpx;
		margin-right: 10rpx;
	}

	.oppt {
		width: 100%;
		height: 300rpx;
	}

	/* 弹窗 */
	.MaskLayer {
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0rpx;
		left: 0rpx;
		/* z-index: 11; */
		background: #000000;
		opacity: 0.6;
	}

	.gif>view>image {
		width: 160rpx;
		height: 160rpx;
	}

	.gif>view>view {
		color: #FFFFFF;
		text-align: center;
		margin-top: 10rpx;
		font-size: 28rpx;
	}

	.CPM,
	.gif {
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		position: fixed;
		top: 0;
		left: 0;
		/* z-index: 11; */
	}

	.CPM_box {
		width: 400rpx;
		height: 300rpx;
		border-radius: 50rpx;
		background: rgb(241, 241, 241);
		padding: 50rpx;
		position: relative;
	}

	.CPM_box>view:nth-child(1) {
		font-size: 34rpx;
		text-align: center;
		margin-top: 20rpx;
	}

	.CPM_box>view:nth-child(2) {
		font-size: 30rpx;
		width: 100%;
		height: 80rpx;
		border-radius: 45rpx;
		margin-top: 40rpx;
		background-color: #1CBBB4;
		color: #FFFFFF;
		text-align: center;
		line-height: 80rpx;
	}

	.CPM_box>view:nth-child(3) {
		font-size: 30rpx;
		width: 100%;
		height: 80rpx;
		border-radius: 45rpx;
		margin-top: 40rpx;
		background-color: rgb(201, 201, 201);
		color: #FFFFFF;
		text-align: center;
		line-height: 80rpx;
	}

	/* 删除弹窗 */
	.fixedes {
		width: 100%;
		height: 100vh;
		position: fixed;
		top: 0;
		bottom: 0;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.fixedbox {
		width: 400rpx;
		height: 240rpx;
		border-radius: 20rpx;
		background: #FFFFFF;
		overflow: hidden;
		z-index: 99;
	}

	.fixedboxTop {
		height: 150rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-bottom: 1rpx solid #DDDDDD;
		font-weight: 600;
	}

	.fixedboxBottom {
		height: 90rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.fixedboxBottom>view {
		width: 50%;
		height: 90rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.fixedboxBottom>view:nth-child(1) {
		border-right: 1rpx solid #DDDDDD;
		color: #666666;
	}

	.fixedboxBottom>view:nth-child(2) {
		color: #21D2A1;
	}
</style>
